package com.zpark.servlet_request;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Arrays;

/**
 * @PackageName: com.zpark.servlet_request
 * @ClassName: ServletRequestDemo04
 * @Description:
 * @author: RZS
 * @date: 2023/3/9  16:16
 */
@WebServlet("/sq04.do")
public class ServletRequestDemo04 extends HttpServlet {
    @Override
    protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // 解决响应乱码问题
        //response.setContentType();
        /*
            1、获取请求转发的请求对象绑定数据（获取请求域对象中的数据）
            2、将获取的数据输出到浏览器
         */
        System.out.println("ServletRequestDemo04");
        String[] user = (String[]) request.getAttribute("user");
        response.getWriter().println("<h1>" + Arrays.toString(user) + "</h1>");
    }
}
